<?php
/**
 * @copyright   Copyright (c) 2017 https://www.sapixx.com All rights reserved.
 * @license     Licensed (http://www.apache.org/licenses/LICENSE-2.0).
 * @author      pillar<ltmn@qq.com>
 * 订单数据
 */
namespace app\allwin\model;
use think\Model;

class AllwinEcardOrder extends Model{
    
    protected $pk    = 'id';

    /**
     * @return \think\model\relation\HasOne
     * 用户
     */
    public function user(){
        return $this->hasOne('app\common\model\SystemUser','id','uid');
    }
    /**
     * @param $data
     * @param $order_no
     * 购买商品生成订单数据
     */
    public static function insertOrder($data,$order_no){
        $order     = [
            'member_miniapp_id' => $data['member_miniapp_id'],
            'card_id'           => $data['card_id'],
            'uid'               => $data['uid'],
            'order_no'          => $order_no,
            'status'            => 0,
            'paid_at'           => 0,
            'shop_id'           => $data['id'],
            'amount'            => $data['amount'],
            'create_time'       => time()
        ];
        self::create($order);
    }
}